<?php class Model_Email extends Database
{	
	function Model_Email(){
		$this->email = EMAILS;			
		$this->Database();
	}	
	// for add emaiil
	function addEmail( $array ){
		$this->InsertData( $this->email , $array );		
		$insertId = mysql_insert_id();
		return $insertId;
	}
	// for edit email
	function editEmailById($array,$id){
		$this->UpdateData($this->email,$array,"email_id",$id,0);		
		
		
	}		
	// for delete email
	function deleteEmailById($Id){
		$this->DeleteData($this->email,"email_id",$Id);
	}
	// get all email value
	function getAllEmailByValue( $val,$col1, $limit='' , $offset=''){
		$fields = array();	
		$tables = array( $this->email);
		if($val!='Email'){
			$where =array("(type LIKE '%".$val."%' || from_email LIKE '%".$val."%')" );
		}
		else{
			$where=array();
		}
		if($col1=='1')
			$order = array("type DESC");
		else
			$order = array("type ASC");
		$result1 = $this->SelectData( $fields,$tables, $where, $order, $group=array(),$limit,$offset,0 );
		$result= $this->FetchAll( $result1 );
		return $result;
	}
	// get email By ID
	function getEmailById($id){
		$fields=array();
		$tables=array($this->email);
		$where=array("email_id='".$id."'");
		$result1 = $this->SelectData($fields,$tables, $where, $order = array(), $group=array(),$limit = "",0,0);
		$result= $this->FetchRow($result1);
		return $result;		
	}
	
}
?>
